#if ODIN_INSPECTOR
namespace Life.UI.MVC.Editor
{
    using Sirenix.OdinInspector.Editor;
    using Sirenix.Utilities;
    using Sirenix.Utilities.Editor;
    using UnityEditor;
    using UnityEngine;
    
    public class CreateUI : OdinMenuEditorWindow
    {
        private static CreateUI instance;
        [MenuItem("Tools/MVC-UI")]
        private static void OpenWindow()
        {
            var window = GetWindow<CreateUI>();
            window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 600);
            instance = window;
            instance.createData.SettingsData = instance.settingsData;
#if !MVCUI_CUSTOM_ENABLED
            instance.typesData.SettingsData = instance.settingsData;
#endif
        }
        
        // [MenuItem("Tools/MVC-UI/CloseWindow")]
        // private static void CloseWindow()
        // {
        //     if (instance != null)
        //     {
        //         instance.Close();
        //         instance = null;
        //     }
        // }
        
        [SerializeField]
        private CreateData createData = new CreateData();
        [HideInInspector]
        [SerializeField]
        private SettingsData settingsData = new SettingsData();
#if !MVCUI_CUSTOM_ENABLED
        [HideInInspector]
        [SerializeField]
        private TypesData typesData = new TypesData();
#endif
        
        protected override OdinMenuTree BuildMenuTree()
        {
            OdinMenuTree tree = new OdinMenuTree(supportsMultiSelect: true)
            {
                { "Creator",                           this,                           EditorIcons.House                       },
#if !MVCUI_CUSTOM_ENABLED
                { "UI Types",                this.typesData                                                           },
#endif
                { "Settings",                this.settingsData                                                           }
            };


            //tree.Add("Creator", new GUIContent("Creator"));
            //tree.Add("Menu/Items/Are/Created", new GUIContent("And can be overridden"));

            tree.SortMenuItemsByName();

            // As you can see, Odin provides a few ways to quickly add editors / objects to your menu tree.
            // The API also gives you full control over the selection, etc..
            // Make sure to check out the API Documentation for OdinMenuEditorWindow, OdinMenuTree and OdinMenuItem for more information on what you can do!

            return tree;
        }
    }
}
#endif